home *** CD-ROM | disk | FTP | other *** search
/ World of Video / World of Video.iso / gfxprograms / 3dprograms / rayshade-4.0 / fixes / fix024 / libshade / viewing.c.diff < prev    next >
Text File  |  1995-02-13  |  2KB  |  72 lines

  1. *** viewing.c    Mon Oct 11 14:59:56 1993
  2. --- viewing.c.frac    Mon Oct 11 14:46:03 1993
  3. ***************
  4. *** 249,255 ****
  5.   Pixel *color;        /* resulting color */
  6.   int sample;        /* sample number */
  7.   {
  8. !     Float dist;
  9.       HitList hitlist;
  10.       Color ctmp, fullintens;
  11.       extern void focus_blur_ray(), ShadeRay();
  12. --- 249,255 ----
  13.   Pixel *color;        /* resulting color */
  14.   int sample;        /* sample number */
  15.   {
  16. !     Float dist, temp;
  17.       HitList hitlist;
  18.       Color ctmp, fullintens;
  19.       extern void focus_blur_ray(), ShadeRay();
  20. ***************
  21. *** 258,263 ****
  22. --- 258,264 ----
  23.        * Calculate ray direction.
  24.        */
  25.       Stats.EyeRays++;
  26. +         ray->type = EYE_RAY;
  27.       ray->dir.x = Screen.firstray.x + x*Screen.scrnx.x + y*Screen.scrny.x;
  28.       ray->dir.y = Screen.firstray.y + x*Screen.scrnx.y + y*Screen.scrny.y;
  29.       ray->dir.z = Screen.firstray.z + x*Screen.scrnx.z + y*Screen.scrny.z;
  30. ***************
  31. *** 280,285 ****
  32. --- 281,293 ----
  33.       fullintens.r = fullintens.g = fullintens.b = 1.;
  34.       dist = FAR_AWAY;
  35.       hitlist.nodes = 0;
  36. +         ray->viewpoint = ray->pos;
  37. +         ray->viewdist = 0.;
  38. +         ray->width = 2.*tan(deg2rad(Camera.hfov/2.))/Screen.xres;
  39. +         if ((temp = 2.*tan(deg2rad(Camera.vfov/2.))/Screen.yres) > ray->width) ray->width = temp;
  40. +         ray->stretch = 1.;
  41.       (void)TraceRay(ray, &hitlist, EPSILON, &dist);
  42.       ShadeRay(&hitlist, ray, dist, &Screen.background, &ctmp, &fullintens);
  43.       color->r = ctmp.r;
  44. ***************
  45. *** 291,293 ****
  46. --- 299,321 ----
  47.           color->alpha = 0.;
  48.       }
  49.   }
  50. + Float PixelSize(ray, dist)
  51. + Ray *ray;
  52. + Float dist;
  53. + {
  54. +         Float s, d;
  55. +         d = dist / ray->stretch;
  56. +         if (ray->viewdist < EPSILON)    /* eye rays */ 
  57. +                 s = ray->width * d;
  58. +         else if (ray->viewdist < FAR_AWAY)   /* infinite light sources !! */
  59. +                 s = ray->width / ray->viewdist * (d + ray->viewdist);
  60. +     else 
  61. +         s = ray->width;
  62. +         s = fabs(s);
  63. +         if (s < EPSILON) return EPSILON;
  64. +         return s;
  65. + }
  66.